Sets the attribute information for a specified file.
指定ファイルの属性情報を設定します。
SetAttr FileName As String, Attribute As Integer
SetAttr FileName As String, Attribute As Integer
FileName: Name of the file, including the path, that you want to test attributes of. If you do not enter a path, SetAttr searches for the file in the current directory. You can also use URL notation.
FileName:属性を確認するファイルの名前およびパス。パスを指定しないと場合、SetAttr は、現在のディレクトリ中で該当ファイルを検索します。またURL 指定を用いることもできます。
Attribute: Bit pattern defining the attributes that you want to set or to clear:
Attribute: 設定ないし解除する属性情報を指定するビットパターン。
Value
値
0 : Normal files.
0 : 通常のファイル。
1 : Read-only files.
1 : 読み取り専用のファイル。
32 : File was changed since last backup (Archive bit).
32 : 前回のバックアップ時から変更のあったファイル (アーカイブビット)。
You can set multiple attributes by combining the respective values with a logic OR statement.
これらの属性値は、論理演算用の OR ステートメントと組み合わせて指定することもできます。
Sub ExampleSetGetAttr
Sub ExampleSetGetAttr
On Error Goto ErrorHandler REM Define target for error-handler
On Error Goto ErrorHandler REM エラーハンドラ用ターゲットを設定
If Dir("C:\test",16)="" Then MkDir "C:\test"
If Dir("C:\test",16)="" Then MkDir "C:\test"
If Dir("C:\test\autoexec.sav")="" THEN Filecopy "c:\autoexec.bat", "c:\test\autoexec.sav"
If Dir("C:\test\autoexec.sav")="" THEN Filecopy "c:\autoexec.bat", "c:\test\autoexec.sav"
SetAttr "c:\test\autoexec.sav" ,0
SetAttr "c:\test\autoexec.sav" ,0
Filecopy "c:\autoexec.bat", "c:\test\autoexec.sav"
Filecopy "c:\autoexec.bat", "c:\test\autoexec.sav"
SetAttr "c:\test\autoexec.sav" ,1
SetAttr "c:\test\autoexec.sav" ,1
print GetAttr( "c:\test\autoexec.sav" )
print GetAttr( "c:\test\autoexec.sav" )
end
End
ErrorHandler:
ErrorHandler:
Print Error
Print Error
end
End
end sub
end sub